package com.toocms.jinjuhang.ui.mine.contact_us

import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableField
import com.toocms.jinjuhang.R
import com.toocms.jinjuhang.BR
import com.toocms.tab.base.ItemViewModel
import com.toocms.tab.binding.ItemBinding

class ContactUsItemModel(
    viewModel: ContactUsModel,
    val title: ObservableField<String>,
    val telItems: List<ContactUsTelItem>
) :
    ItemViewModel<ContactUsModel>(viewModel) {

    val items = ObservableArrayList<ContactUsTelItemModel>()
    val itemBinding = ItemBinding.of<ContactUsTelItemModel>(
        BR.contactUsTelItemModel,
        R.layout.item_contact_us_tel
    )

    init {
        telItems.forEach {
            items += ContactUsTelItemModel(
                viewModel,
                ObservableField(it.title), ObservableField(it.phoneCode), ObservableField(it.extend)
            )
        }
    }

}